package com.demo.wrapper.interfaces;

/**
 * 构建Builder接口
 *
 * @param <QueryBuilder>  QueryBuilder
 * @param <SourceBuilder> SourceBuilder
 * @author 19242
 */
public interface IBuilderWrapper<QueryBuilder, SourceBuilder> {

    /**
     * 将收集的条件转成QueryBuilder，自动过滤嵌套相同的子条件，不支持not过滤
     *
     * @return
     */
    default QueryBuilder queryBuilder() {
        return queryBuilder(true);
    }

    /**
     * 将收集的条件转成QueryBuilder
     *
     * @param autoFilter true自动过滤，不支持not 如： 1=1 and (2=2 and 3=3) -> 1=1 and 2=2 and 3=3
     * @return
     */
    QueryBuilder queryBuilder(boolean autoFilter);

    /**
     * 将收集的所有条件转SearchSourceBuilder
     *
     * @return SearchSourceBuilder
     */
    default SourceBuilder sourceBuilder() {
        return sourceBuilder(true);
    }

    /**
     * 将收集的所有条件转SearchSourceBuilder
     *
     * @param autoFilter 同queryBuilder
     * @return SearchSourceBuilder
     */
    SourceBuilder sourceBuilder(boolean autoFilter);
}
